import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';

// class Cmp1 extends StatefulWidget {
//   Cmp1({Key key}) : super(key: key);

//   @override
//   _Cmp1State createState() => _Cmp1State();
// }

// class _Cmp1State extends State<Cmp1> {
//   var a = 10;

//   @override
//   Widget build(BuildContext context) {
//     return Container(
//       child: Row(
//         children: [
//           Text('a:$a'),
//           FlatButton(
//               onPressed: () {
//                 setState(() {
//                   a += 1;
//                 });
//               },
//               child: Text('我是按钮'),
//               color: Colors.blue)
//         ],
//       ),
//     );
//   }
// }

// ignore: must_be_immutable
class Cmp1 extends HookWidget {
  @override
  Widget build(BuildContext context) {
    var a = useState(10);
    return Container(
      child: Row(
        children: [
          Text('a:${a.value}'),
          FlatButton(
              onPressed: () {
                a.value++;
              },
              child: Text('我是按钮'),
              color: Colors.blue)
        ],
      ),
    );
  }
}
